<script src="/javascripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>
<script src="/javascripts/mce_editor.js" type="text/javascript"></script>
<script src="/javascripts/new_product.js" type="text/javascript"></script>
<script src="/javascripts/jquery.selectboxes.js" type="text/javascript"></script>

<div class='form'>
  <% form_for [@category,@product],:html=>{:multipart=>true} do |f| %>
    <%= f.error_messages %>
    <p>
      <label for="product_category_id">类别</label>
      <select id="product_category_id" name="product[category_id]">
        <%=options_for_select(categories_options,@category.id.to_s)%>
      </select>
      <a href="/categories"  class="action_edit">管理类别</a>
    </p>
    <p>
      <label for="product_brand_id">品牌</label>
      <%=  select("product", "brand_id", Brand.find(:all,:order => 'sort_order desc').collect {|b| [ b.name, b.id ] },{:prompt =>"请选择"}) %>
      <a href="javascript:void(0);" onclick="$('#create_brand').show();" class="action_add">添加新品牌</a> |
      <a href="/brands"  class="action_edit">管理品牌</a>
    </p>
    <div id="create_brand" class="toolbar" style="display:none;">
      <div class="title">添加新品牌</div>
      <b>品牌名称</b>
      <input name="brand[name]" id="brand_name"></input>
      <a href="javascript:void(0);" onclick="addBrand();" class="action_add">添加</a>
      <a href="javascript:void(0);" onclick="$('#create_brand').hide();" class="action_back">取消</a>
    </div>

    <p>
      <label for="product_name">名称</label>
      <%= f.text_field :name %>
    </p>

    <p>
      <label for="product_model">型号</label>
      <%= f.text_field :model %>
    </p>

    <p>
      <label for="product_sn">货号</label>
      <%= f.text_field :sn %>
    </p>
    <p>
      <label for="product_image─url">上传图片</label>
      <%= file_column_field "product", "image_url" %>
    </p>
    <p>
      <label for="product_quantity">数量</label>
      <%= f.text_field :quantity %>
    </p>
    <p>
      <label for="product_purchase_price">进货价</label>
      <%= f.text_field :purchase_price %>
    </p>
    <p>
      <label for="product_cost_price">成本价</label>
      <%= f.text_field :cost_price %>
    </p>
    <p>
      <label for="product_retail_price">零售价</label>
      <%= f.text_field :retail_price %>
    </p>

    <p>
      <label for="product_active">可用</label>
      <%= f.check_box :active %>
    </p>

    <p>
      <label for="product_description">描述</label>
      <% use_tinymce -%>
      <%= f.text_area :description,:class =>"mce-editor" %>
    </p>

    <p>
      <%= f.submit button_name,:class=>'submit' %>
    </p>
  <% end %>
</div>